#ifndef _WEBPAGE_H_
#define _WEBPAGE_H_

#include "SplitTool.h"
#include "simhash/Simhasher.hpp"
#include <iostream>
#include <map>
#include <string>
#include <tinyxml2.h>
#include <vector>

using namespace simhash;
using std::map;
using std::string;
using std::vector;

// 传入html的string，将其解析，提取 docid，title，url，content，hash
class WebPage {
  public:
    friend bool operator==(const WebPage &lhs, const WebPage &rhs);
    friend bool operator<(const WebPage &lhs, const WebPage &rhs);
    friend ostream &operator<<(ostream &os, const WebPage &page);

    //  WebPage(string &, string &,string &);
    WebPage(string &);
    // int getDocid();
    string getDoc();
    // string getContent();
    uint64_t getHash();
    map<string, int> &getWordsMap();
    void setDocid(int);

  private:
    string _doc;
    int _docid;
    // string _docTitle;
    // string _docUrl;
    // string _docContent;
    uint64_t _dochash;
    map<std::string, int> _wordsMap;
    static Simhasher simhasher; // 减少性能开销
};

#endif